#include <stdio.h>
#include <math.h>
#include "app_config.h"
#include "ota.h"

/*
    1. WiFi 选项 - 1.配网模式 2.状态及信息
*/

static void timer_task_cb(struct _lv_timer_t *timer)
{
}

lv_timer_t *display_config_enter(lv_obj_t *parent)
{
    if (!parent)
        return NULL;

    lv_obj_t *list = lv_list_create(parent);
    lv_obj_set_size(list, LV_PCT(100), LV_PCT(100));
    lv_obj_set_style_radius(list, 0, LV_PART_MAIN);
    lv_obj_set_style_border_width(list, 0, LV_PART_MAIN);
    lv_obj_set_style_pad_row(list, 0, LV_PART_MAIN);
    lv_obj_set_flex_flow(list, LV_FLEX_FLOW_COLUMN);
    lv_obj_set_style_bg_color(list, lv_color_make(0, 0, 0), LV_PART_MAIN);
    lv_obj_set_style_bg_opa(list, LV_OPA_50, LV_PART_MAIN);
    lv_obj_set_scrollbar_mode(list, LV_SCROLLBAR_MODE_OFF);

    lv_timer_t *timer = lv_timer_create(timer_task_cb, 1000, list);
    lv_timer_pause(timer);
    return timer;
}

void display_config_level(lv_timer_t *timer, void *user_data)
{
    lv_obj_t *obj = timer->user_data;
    lv_timer_del(timer);
    lv_obj_del(obj);
}
uint8_t display_config_update_cb(lv_timer_t *timer, void *user_data, uint8_t event)
{
    lv_obj_t *list = timer->user_data;
    if (event == APP_EVENT_TYPE_NEXT)
    {
        return 1;
    }
    else if (event == APP_EVENT_TYPE_CLICK)
    {
        return 1;
    }
    else if (event == APP_EVENT_TYPE_CONFIRM) /* 进入 / 退出页面 */
    {
        display_config_level(timer, user_data);
        return 0;
    }
    return 0;
}

config_item_s display_config_item = {
    .name = "屏幕",
    .enter = display_config_enter,
    .level = display_config_level,
    .update = display_config_update_cb,
    .user_data = NULL,
};
